package com.example.rocketmqdemo.message;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName MyCustomer1
 * @Description TODO
 * @Author 郭敖
 * @Date 2023年12月05日 22:52
 * @Version 1.0
 */
@Component
@Slf4j
@RocketMQMessageListener(topic = "test-topic",consumerGroup = "group1",messageModel = MessageModel.BROADCASTING)
public class MyCustomer1 implements RocketMQListener {
    @Override
    public void onMessage(Object o) {
        log.info("收到的test-topic的消息为"+o);
        System.out.println("收到的test-topic的消息为"+o);
        // 如果手动确认消息  只需要抛出个异常即为消费失败   rocketMQTemplate会捕获异常 提交消费的消费状态为消费不成功
    }
}
